﻿(function () {
    "use strict";

    WinJS.Namespace.define("ClassExplorer.Services", {
        populateClasses: function() {

            var url = "http://registrar.sas.cornell.edu/courses/roster/SP13/xml/";

            return WinJS.xhr({ url: url }).then(
                function (request) {
                    var json = $.xml2json(request.responseXML);
                    var subjects = json.subject;
                    ClassExplorer.Data.Subjects = new ClassExplorer.Data.Models.SubjectsModel(subjects);
                });
        },
        populateCourses: function(xmlFeed) {
            return WinJS.xhr({ url: xmlFeed }).then(
                function (request) {
                    var json = $.xml2json(request.responseXML);
                    var courses = json.course;
                    ClassExplorer.Data.Courses = new ClassExplorer.Data.Models.CoursesModel(courses);
                });
        }
    });
})();